<?php
class Admin_IndexController extends Zend_Controller_Action {
	public function init() {
		/* Initialize action controller here */
	}
	public function indexAction() {
		
	}
	
	public function loginAction() {
		$this->view->errors = array ();
		if ($this->getRequest ()->isPost ()) {
			$email = $this->_request->getPost ( 'email' );
			$password = $this->_request->getPost ( 'password' );
				
			if (empty ( $email ) || empty ( $password )) {
				$this->view->errors [] = "Làm ơn nhập địa chỉ email và password";
			} else {
	
				// Did the participant successfully login?
				if ($email == 'admin@admin.com' & $password == 'admin') {
					$session = new Zend_Session_Namespace('login');
					$session->login = $email;
					$this->_redirect ( '/admin' );
				} else {
					$this->view->errors [] = "Đăng nhập thất bại, làm ơn thử lại.";
				}
			}
		}
	}
	
	public function logoutAction(){
		$session = new Zend_Session_Namespace('login');
		unset($session->login);
		$this->redirect("/admin");
	}
	
}

